#AccessKey ID： 0198A7F7EB6B7ACBA1A94BB0B09B5285    AccessKey Secret：0198A7F7EB6B7AC0890AEDE85B143489
import requests
import json
import time
import jwt
ak = "0198A7F7EB6B7ACBA1A94BB0B09B5285"
sk = "0198A7F7EB6B7AC0890AEDE85B143489"
def encode_jwt_token(ak, sk):
    headers = {
        "alg": "HS256",
        "typ": "JWT"
    }
    payload = {
        "iss": ak,
        "exp": int(time.time()) + 1800, # 有效时间，此处示例代表当前时间+1800s(30min)
        "nbf": int(time.time()) - 5 # 开始生效的时间，此处示例代表当前时间-5秒
    }
    token = jwt.encode(payload, sk, headers=headers)
    return token
#获取生成的API_TOKEN
authorization = encode_jwt_token(ak, sk)
print(authorization)

headers = {
    'Authorization':f'Bearer {authorization}',
    'Content-Type': 'application/json'
}
url='https://mhapi.sensetime.com/v1/imgenstd/imgen'
data={
    'model_id':'',
    'prompt':'一堆石头'
}